﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace TEST
{
    public partial class RichText : UserControl
    {
        public RichText()
        {
            InitializeComponent();
            this.Load += RichText_Load;
        }

        private void RichText_Load(object sender, EventArgs e)
        {
            comboBox1.Text = "Bold";
            richTextBox1.Text = "新回享计划是百度经验全新推出的贡献者创收计划，主要通过现金激励的方式，\r\n+ " +
                                "让更多爱生活、爱分享的人，用经验创造价值。\r\n" + "成为新回享作者，此后发布的每篇经验都将获得现金回报。\r\n";
            textBox2.Text = "百度";
            textBox1.Text = "20";
            comboBox1_SelectedIndexChanged(null, null);
        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            comboBox1.Items.Clear();
            comboBox1.Items.Add("Bold"); //加粗文本&nbsp;           
            comboBox1.Items.Add("Italic"); //倾斜文本&nbsp;           
            comboBox1.Items.Add("Regular"); //普通文本&nbsp;           
            comboBox1.Items.Add("Strikeout"); //中间有直线通过的文本&nbsp;                      cb_zx.Items.Add("Underline"); //带下划线文本&nbsp;       
        }
        private void button1_Click(object sender, EventArgs e)
        {
            textBox2.Text = richTextBox1.Text.Substring(richTextBox1.SelectionStart, richTextBox1.SelectionLength);
            //Color ztys;
            if (colorDialog1.ShowDialog() == DialogResult.OK)
            {

                richTextBox1.Select(richTextBox1.SelectionStart, richTextBox1.SelectionLength);
                richTextBox1.SelectionColor = colorDialog1.Color;
                //richTextBox1.SelectionBackColor = Color.Green;
                //int size = 20;
                //try { size = Convert.ToInt32(textBox1.Text); }
                //catch { size = 20; }
                //richTextBox1.SelectionFont = new Font("bold", 10);

            }
        }

        private void richTextBox1_SelectionChanged(object sender, EventArgs e)
        {
            textBox2.Text = richTextBox1.Text.Substring(richTextBox1.SelectionStart, richTextBox1.SelectionLength);
        }
    }
}
